package com.jydd.singlekotlinmvvm.comm.feature.search.controller

import com.airbnb.epoxy.Typed2EpoxyController
import com.jydd.singlekotlinmvvm.comm.component.LoadingFooterHolder
import com.jydd.singlekotlinmvvm.comm.model.response.RepoInfo

/**
 * created by 韦敏敏
 * on 2020/1/21
 */
class SearchController(private  val itemClick: (item : RepoInfo) -> Unit) : Typed2EpoxyController<List<RepoInfo>, Boolean>() {
    override fun buildModels(data: List<RepoInfo>?, hasMore: Boolean?) {
        data?.forEach {
            RepoModule(it) {
                itemClick.invoke(it)

            }.id(it.id)
                .addTo(this)
        }
        LoadingFooterHolder().id("footer").addIf(hasMore == true, this)
    }
}